package recharge_management

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UsdtInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// usdt--获取一条记录
func NewUsdtInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsdtInfoLogic {
	return &UsdtInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UsdtInfoLogic) UsdtInfo(req *types.UsdtInfoRequest) (resp *types.UsdtInfoResponse, err error) {
	rpcReq := rpc.UsdtInfoRequest{
		Id: req.Id,
	}

	rpcResp, err := l.svcCtx.AssetsRpc.TenantChannel.UsdtInfo(l.ctx, &rpcReq)
	if err != nil {
		return nil, err
	}

	return &types.UsdtInfoResponse{
		Usdt: types.Usdt{
			Id:        rpcResp.Id,
			CreatedAt: rpcResp.CreatedAt,
			UpdatedAt: rpcResp.UpdatedAt,
			Name:      rpcResp.Name,
			UsdtType:  rpcResp.UsdtType,
			QrCode:    rpcResp.QrCode,
			Address:   rpcResp.Address,
		},
		CommonResp: types.CommonResp{
			Code:    rpcResp.CommonResp.Code,
			Message: rpcResp.CommonResp.Message,
		},
	}, nil
}
